package com.example.demo_job.mapper;



import com.example.demo_job.entity.Position;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PositionMapper {

    @Select("SELECT pid from position where cid=#{cid} and pname=#{pname}")
    int findpid(int cid, String pname);

    @Select("SELECT * FROM position")
    List<Position> findPositionByHot();

    @Select("SELECT pinfo FROM position where cid=#{cid} and pname=#{pname}")
    String findPositionPath(int cid, String pname);

    @Select("select * from position where cid=(select cid from company where cusername=#{cusername})")
    List<Position> ShowPosition(String cusername);

    @Select("select pinfo from position where pid=#{pid}")
    String FindInfo(int pid);


    @Delete("delete from position where pid = #{pid}")
    void DeletePosition(int pid);

    @Delete("delete from recruit where pid = #{pid}")
    void DeleteRecruit(int pid);


    @Insert("Insert into position (cid,pname,pinfo,salary,hot,paddress,enumber,anumber) values(#{cid},#{pname},#{pinfo},#{salary},0,#{paddress},#{enumber},0)")
    void InsertPosition(int cid, String pname, String pinfo, double salary, String paddress, int enumber);

    @Select("select pinfo from position where pid=#{pid}")
    String findPinfo(int pid);

    @Select("select * from position where pid=#{pid}")
    Position findPositionBypid(int pid);

    @Update("update position set pname =#{pname},salary =#{salary},paddress=#{paddress},enumber=#{enumber} where pid=#{pid}")
    void updatePosition(int pid, String pname, double salary, String paddress, int enumber);

    @Select("select pname from position where pid=#{pid}")
    String findPnameBypid(int pid);

    @Select("select pid from position where cid=#{cid1} AND pname =#{pname}")
    int findPidByPnameAndCid(int cid1, String pname);

    @Select("select count(*) from recruit where pid = #{pid}")
    int findapplynumBypid(int pid);


    @Select("select * from position where cid=#{cid} AND pname like #{value}")
    List<Position> searchPosition(int cid, String value);
}
